import numpy as np
import pandas as pd


def main():
    n_periods = 16
    n_samples = 1024
    x = np.linspace(0, 2*np.pi*n_periods, n_samples)
    y = np.sin(x)
    x = x / (np.pi*n_periods) - 1  # normalize between -1 and 1

    data = np.stack((x, y), axis=1)
    data_envs = np.split(data, n_periods)
    dfs = []
    for domain, data_env in enumerate(data_envs):
        df = pd.DataFrame(data_env, columns=["x", "y"])
        df.insert(0, "domain", domain)
        dfs.append(df)
    df = pd.concat(dfs, axis=0)
    df.to_csv(f"sin.csv", index=False)


if __name__=="__main__":
    main()